home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / EC.H < prev    next >
C/C++ Source or Header  |  1988-04-12  |  3KB  |  85 lines

  1. /* Stuff specific to the 3-Com 3C500 Ethernet controller board */
  2. #define    EC_MAX    3
  3. extern unsigned nec;    /* Actual number of Ethernet controllers */
  4.  
  5. /* Find base address of specified device */
  6. #define    IE(dev)    (ec_dev[dev].addr)
  7.  
  8. /* The various IE command registers */
  9. #define    EDLC_ADDR(num)    (num)        /* EDLC station address, 6 bytes */
  10. #define    EDLC_RCV(num)    ((num)+0x6)    /* EDLC receive csr */
  11. #define    EDLC_XMT(num)    ((num)+0x7)    /* EDLC transmit csr */
  12. #define    IE_GP(num)    ((num)+0x8)    /* GP pointer */
  13. #define    IE_RP(num)    ((num)+0xa)    /* Receive buffer pointer */
  14. #define    IE_SAPROM(num)    ((num)+0xc)    /* window on station addr prom */
  15. #define    IE_CSR(num)    ((num)+0xe)    /* IE command/status */
  16. #define    IE_BFR(num)    ((num)+0xf)    /* window on packet buffer */
  17.  
  18. /* Bits in EDLC_RCV, interrupt enable on write, status when read */
  19. #define    EDLC_NONE    0x00    /* match mode in bits 5-6, write only */
  20. #define    EDLC_ALL    0x40    /* promiscuous receive, write only */
  21. #define    EDLC_BROAD    0x80    /* station address plus broadcast */
  22. #define    EDLC_MULTI    0xc0    /* station address plus multicast */
  23.  
  24. #define    EDLC_STALE    0x80    /* receive CSR status previously read */
  25. #define    EDLC_GOOD    0x20    /* well formed packets only */
  26. #define    EDLC_ANY    0x10    /* any packet, even those with errors */
  27. #define    EDLC_SHORT    0x08    /* short frame */
  28. #define    EDLC_DRIBBLE    0x04    /* dribble error */
  29. #define    EDLC_FCS    0x02    /* CRC error */
  30. #define    EDLC_OVER    0x01    /* data overflow */
  31.  
  32. #define    EDLC_RERROR    (EDLC_SHORT|EDLC_DRIBBLE|EDLC_FCS|EDLC_OVER)
  33. #define    EDLC_RMASK    (EDLC_GOOD|EDLC_ANY|EDLC_RERROR)
  34.  
  35. /* bits in EDLC_XMT, interrupt enable on write, status when read */
  36. #define    EDLC_IDLE    0x08    /* transmit idle */
  37. #define    EDLC_16        0x04    /* packet experienced 16 collisions */
  38. #define    EDLC_JAM    0x02    /* packet experienced a collision */
  39. #define    EDLC_UNDER    0x01    /* data underflow */
  40.  
  41. /* bits in IE_CSR */
  42. #define    IE_RESET    0x80    /* reset the controller (wo) */
  43. #define    IE_XMTBSY    0x80    /* Transmitter busy (ro) */
  44. #define    IE_RIDE        0x40    /* request interrupt/DMA enable (rw) */
  45. #define    IE_DMA        0x20    /* DMA request (rw) */
  46. #define    IE_EDMA        0x10    /* DMA done (ro) */
  47.  
  48. #define    IE_BUFCTL    0x0c    /* mask for buffer control field (rw) */
  49. #define    IE_LOOP        0x0c    /* 2 bit field in bits 2,3, loopback */
  50. #define    IE_RCVEDLC    0x08    /* gives buffer to receiver */
  51. #define    IE_XMTEDLC    0x04    /* gives buffer to transmit */
  52. #define    IE_SYSBFR    0x00    /* gives buffer to processor */
  53.  
  54. #define    IE_CRC        0x01    /* causes CRC error on transmit (wo) */
  55. #define    IE_RCVBSY    0x01    /* receive in progress (ro) */
  56.  
  57. /* miscellaneous sizes */
  58. #define    BFRSIZ        2048    /* number of bytes in a buffer */
  59.  
  60. struct estats {
  61.     long recv;        /* Good packets received */
  62.     long bad;        /* Bad receive packets */
  63.     long over;        /* Overflow errors */
  64.     long drop;        /* Dropped because RX queue too long */
  65.     long nomem;        /* Dropped because buffer malloc failed */
  66.     long intrpt;        /* Interrupts */
  67.     long xmit;        /* Total output packets */
  68.     long timeout;        /* Transmitter timeouts */
  69.     long jam;        /* Collisions */
  70.     long jam16;        /* 16 successive collisions */
  71. };
  72. struct ec {
  73.     unsigned base;        /* Base I/O address */
  74.     unsigned vec;        /* Interrupt vector */
  75.     struct mbuf *rcvq;    /* Queue of incoming packets */
  76.     unsigned rcvcnt;    /* Number of packets on queue */
  77.     unsigned rcvmax;    /* Maximum length of rcvq */
  78.     struct estats estats;    /* Controller statistics */
  79.     short size;        /* Size of current transmit packet */
  80.     struct interface *iface;
  81. };
  82. extern struct ec ec[];
  83.  
  84.     
  85.